package io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class CopyDemo2 {
    public static void main(String[] args) throws IOException {
        FileInputStream fis =new FileInputStream("J0382963.JPG");
        FileOutputStream fos=new FileOutputStream("J0382963_cp2.JPG");

        long satas=System.currentTimeMillis();
        byte[] bay=new byte[1024*10];
        int len;
        while ((len=fis.read(bay))!=-1){//每次读取10kb并判断是否读取到了末尾
            fos.write(bay,0,len);
        }
        long lend=System.currentTimeMillis();
        System.out.println("复制完毕"+(lend-satas)+"ms");
        fis.close();
        fos.close();
























       /* FileInputStream fis =new FileInputStream("J0382963.JPG");
        FileOutputStream fos=new FileOutputStream("J0382963_cp2.JPG");

        long satas=System.currentTimeMillis();
        byte[] bay=new byte[1024*10];
        while (fis.read(bay)!=-1){//每次读取10kb并判断是否读取到了末尾
            fos.write(bay);
        }
        long len=System.currentTimeMillis();
        System.out.println("复制完毕"+(len-satas)+"ms");
        fis.close();
        fos.close();*/
    }
}
